package com.ocom.company.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.company.EntityComDockApi;
import com.ocom.common.entity.master.EntityCompanyRole;
import com.ocom.common.vo.company.CompanyRoleListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoCompanyRole extends BaseMapper<EntityCompanyRole> {

    @Select({"<script>",
            "select \n" +
                    "a.role_id AS role,  \n" +
                    "a.role_name AS roleName, \n" +
                    "a.parent_role AS parentRole, \n" +
                    "b.val AS parentRoleName " +
                    "FROM company_role a \n" +
                    "left join page_enum b ON a.parent_role = b.tip AND b.type = 'systemRole' " +
                    "where a.com_id = #{comId} " +
                    " <when test=\"roleId!=null  \" > "+
                    " AND  a.role_id = #{roleId} "+
                    " </when> "+
                    "ORDER BY a.role_id " +
                    "</script>"})
    List<CompanyRoleListVo> getCompanyRole(@Param("comId") Long comId, @Param("roleId") Long roleId);
}
